package com.cdream.basic.algorithm.leetcode.string;

/**
 * @author cdream
 * @date 6/29/21
 */
public class Question168 {
    public String convertToTitle(int columnNumber) {
        StringBuilder res = new StringBuilder();
        while(columnNumber!=0){
            int mod = (columnNumber-1) % 26+1;
            res.insert(0, (char) (mod + 'A' - 1));
            columnNumber =(columnNumber-mod)/ 26;
        }
        return res.toString();
    }

    public static void main(String[] args) {
        new Question168().convertToTitle(701);
    }
}
